﻿<?php
defined('_JEXEC') or die;

require_once 'Mobile_Detect.php';
$detect = new Mobile_Detect;
if( $detect->isMobile() )
{
	include('step3_mobile.php');
	return;
}

JHtml::_('behavior.keepalive');
//JHtml::_('behavior.formvalidation');
$sess=JFactory::getSession();
$sess=$sess->get("regs1.data");

if($sess){
	$db=JFactory::getDbo();
	$db->setQuery("SELECT id FROM #__users WHERE email=".$db->quote($sess['email']));
	$id_user=$db->loadResult();
}

if(!$id_user)
	jexit("step3 N/A");
?>
<style type="text/css">
	.nohand{cursor:default}
</style>
<div class="wrapper">
	<div class="content" id="booktime-page">
		<div class="col-wrapper clearfix">
			<div class="info">
				
				<ul class="breadcrumb mb20">
					<li><a class="nohand">Personlige oplysninger</a></li>
					<li><a class="nohand">Dit abonnement</a></li>
					<li class="active"><a>Book tid hos din vejleder</a></li>
					<li><a class="nohand">Kostvaner/ ønsker</a></li>
					<li><a class="nohand">Motionsvaner/ ønsker</a></li>
				</ul>
					
				<h1 class="hd">VÆLG VEJLEDER OG BOOK TID</h1>
					<div class="booktime-content clearfix">
						<ul id="foo3">
<?php
						$dbo=JFactory::getDbo();
						$query="SELECT id, name, image, description FROM #__users a , #__user_usergroup_map b WHERE a.id=b.user_id AND b.group_id=5";
						$rows=$dbo->setQuery($query)->loadObjectList();
						//echo '<pre>',print_r($rows),'</pre>';die;
						?>
<?php					foreach ($rows as $item){?>
							<li>
									<img src="<?php echo JURI::root().$item->image?>" alt="">
									<h4><?php echo $item->name;?></h4>
									<?php echo $item->description;?>
<div style="position:absolute;left:50%;white-space:nowrap;bottom:15px">
									<a href="<?php echo JRoute::_('index.php?option=com_users&view=registration&layout=step3');?>#go_sss" class="BT-here clr" onclick="teacher(this,<?php echo $item->id;?>);">Se tider og book tid her</a>
</div>
							</li>
<?php					}?>
						</ul>
						<!--<a id="foo3_next" class="bntNext fr mr340 mt10" href="#">Næste <span class="red"> > </span></a>-->
						<!--<a id="foo3_prev" class="bntPrevious fl ml320 mt10" href="#"><span class="red"> < </span> Tilbage</a>-->
						<div class="clear"></div>
					</div>

					<div class="clear mt20"></div>
					<form name="reg_form4" id="member-registration" method="post" class="form-validate" enctype="multipart/form-data">
					<input type="hidden" name="jform[booktime]" value="" />
					<input type="hidden" name="option" value="com_users" />
					<input type="hidden" name="task" value="registration.step4" />
					<input type="hidden" name ="jform[id_teacher]" id="id_teacher" />
					<input type="hidden" name="jform[day_meeting]" id="day_meeting" value=""/>
					<input type="hidden" name="jform[from_meeting]" id="from_meeting"/>
					<input type="hidden" name="jform[to_meeting]" id="to_meeting"/>
					<input type="hidden" name="jform[message_meeting]" id="message_meeting"/>
					
					<?php echo JHtml::_('form.token');?>
					</form>
			</div>
		</div>
	</div>

<a name="go_sss"></a>
<div id="ssss">
</div>

</div>



<script type="text/javascript" src="templates/fitplan/src/js/jquery.carouFredSel-6.2.1-packed.js"></script>
<script type="text/javascript">
tactive=null;
function save_meeting()
{
	$('#day_meeting').attr('value',$('#day').val());
	$('#from_meeting').attr('value',$('#from').val());
	$('#to_meeting').attr('value',$('#to_nam').val());
	$('#message_meeting').attr('value',$('#subject').val());
	document.reg_form4.submit();
	//jQuery('#close-reveal-modal').click();
	
	
}
function close_meeting()
{
	$('#day_meeting').attr('value','');
	jQuery('#close-reveal-modal').click();
	
	
}

function teacher(o, id){

	if($('#id_teacher').val()!=id){
		if(tactive)
			tactive.removeClass("tactive");
		$('#id_teacher').attr('value',id);
	}
		tactive=$(o.parentNode);
		tactive.addClass("tactive");

	$.ajax({
		type: "POST",
		url: "<?php echo JURI::base()?>index.php?option=com_meeting&id_teacher=" +id,

		dataType: "html",
		success: function(msg){
				$('#ssss').html(msg);
		}
	});
    
}

/*$(document).ready( function(){
	$("#foo3").carouFredSel({
		auto		: false,
		items	: 3,
		scroll	: {
			items			: 3,
			duration			: 1000,
			timeoutDuration	: 2000
		},
		prev		:'#foo3_prev',
		next		:'#foo3_next'
	});
	function pickteacher(d){
		document.reg_form4.elements["jform[tid]"].value=d;
	}
});*/
</script>
<style type="text/css">
	col.busy, td.busy{
		background:#4CAF52;
		border-color: 2px 0x18891F solid;
	}
</style>